import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);

const store = new Vuex.Store({
	state: {
		TOKEN: uni.getStorageSync('token') || '',
		isShare: uni.getStorageSync('token') || false,
		img_url: "https://qitianapp.fornewtech.com/api/",
		userInfo: uni.getStorageSync('userInfo') || {},
	},
	getters: {},
	mutations: {
		setUserInfo(state, data) {
			state.userInfo = {...data}
		},
		setToken(state, data) {
			state.TOKEN = data
		},
		setIsShare(state, data) {
			state.isShare = data
		} 
	},
	actions: {
		Login(context, {
				token,
			}) {
				context.commit('setToken', token)
				uni.setStorageSync('token', token)
			}
		}
})

export default store;